<?php
session_start();
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of feria
 *
 * @author jean
 */
class feriaController extends Controller
{
   
    
    private $_user;
    
    public function __construct() {
        parent::__construct();
        $this->_user = $this->loadModel('usuario');
    }
    public function index()
    {
  
        
        $this->_view->titulo = 'Portada';
        $this->_view->renderizar('feria', 'bandeja',false);
    }
    public function siguiente($pagi,$secc=false)
    {
  
      
       //$this->_view->titulo = 'Portada';
        $this->_view->view('feria/comtenidos/'.$pagi);
    }
    public function feria($pagi ,$secc=false)
    {
     if(@$secc)
         $_SESSION['feria']=$secc;
     
       //$this->_view->titulo = 'Portada';
        $this->_view->view('feria/comtenidos/'.$pagi);
    }
    function acceso() {
        $user=$_POST['username'];
        $pass=$_POST['password_login'];
        $caht=$_POST['defaultReal'];
        $cahths=$_POST['defaultRealHash'];
        
        if ($this->rpHash($caht)==$cahths) {
            $user = $this->_user->authenticate($user,$pass);
            if (@$user) {
                 $r =  true;
            $mens = "Bienvenido" ;
          
                
            }else {
            $r = false;
            $mens = 'Acceso denegados';
        }
        }
         $res = array(
            'form' => $form,
            'res' => $r,
            'mensaje' => $mens
        );
        echo json_encode($res);
        }
       
    
    
    function rpHash($value) {
        $hash = 5381;
        $value = strtoupper($value);
        for ($i = 0; $i < strlen($value); $i++) {
            $hash = ord(substr($value, $i));
        }
        return $hash;
    }

   

}
